import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';

import 'package:focus_widget/focus_widget.dart';
import 'package:quality_ticket/config/color.dart';
import 'package:quality_ticket/config/appbar.dart';
import 'package:quality_ticket/config/quality_dailog.dart';
import 'package:quality_ticket/config/quality_item.dart';
import 'package:quality_ticket/pojo/quality_model.dart';
import 'package:toast/toast.dart';

/*
*
*
* 作业票
*
* */

/*
*
* 今日修改：
*
*
* 5、将多选和单选抽调一个出来
*
*
* */
class DetailsPage extends StatefulWidget {
  const DetailsPage({Key key}) : super(key: key);

  @override
  _DetailsPageState createState() => _DetailsPageState();
}

class _DetailsPageState extends State<DetailsPage> {
  //定义作业必备条件数组数据
  List<String> conditionList = [
    "特种作业人员持证上岗。",
    "作业人员无妨碍工作的职业禁忌。",
    "无超龄或年龄不足人员参与作业。",
    "配备个人安全防护用品，并经检验合格，齐全、完好。",
    "结构性材料有合格证。",
    "按规定需送检的材料送检并符合要求。",
    "编制安全技术措施，安全技术方案制定并经审批或专家论证。",
    "施工人员经安全教育培训，并参加过本工程技术安全措施交底。",
  ];

  //定义审核签名的数据
  List<String> auditSignatureList = [
    "检测负责人",
    "审核人",
    "批准人",
    "监理工程师",
  ];

  //风险等级数组
  List<String> riskLevelList = [
    "一级",
    "二级",
    "三级",
    "四级",
    "五级",
  ];

  //选中的数据
  List<ChoiceModel> choiceLists = [];

  ///查找的数据内容
  List<OperatingConditionsModel>serchOperatingConditionsList=[];

  //作业必备条件
  List<OperatingConditionsModel> OperatingConditionsList = [];

  //封装Wiget布局
  List<Widget> qualityWidgetList = <Widget>[];

  //复测风险等级
  RiskLevelModel riskLevelModel = RiskLevelModel();

  //焦点绑定
  //关键点作业安全措施
  FocusNode _keyPointsFocus = FocusNode();

  //安全综合控制措施
  FocusNode _safetySynthesisFocus = FocusNode();

  //变化情况
  FocusNode _changesFocus = FocusNode();

  //控制措施
  FocusNode _controlMeasuresFocus = FocusNode();

  //作业必备条件全选
  bool allCheckVal = false;

  //判断基础信息是否收起
  bool isShowBaseInfo = true;

  //判断作业票信息是否收起
  bool isShowQualityBaseInfo = true;

  //判断具体人员分工是否收起
  bool isShowDivisionOfLabor = true;

  //判断主要风险是否收起
  bool isShowMainRisks = true;

  //判断作业必备条件是否收起
  bool isShowOperationPrerequisites = true;

  //判断作业过程风险是否收起
  bool isShowProcessRisk = true;

  //判断审核签名是否收起
  bool isShowAuditSignature = true;

  //判断结束日期是否能够选择
  bool isSingleClickEndTime = false;

  //计划开始--结束时间
  String panStartTime, panEndTime;
  String year, months, days;

  //添加的天数
  int addDays = 29;
  DateTime startTime, endTime, panEnd, panStart;

  @override
  void initState() {
    // TODO: implement initState
    super.initState();
    //初始化作业必备条件数组
    for (var i = 0; i < conditionList.length; i++) {
      OperatingConditionsModel model = OperatingConditionsModel(
          id: i, condition_val: conditionList[i], checkValue: false);
      OperatingConditionsList.add(model);
    }

    //初始化时间
    startTime = DateTime.now();
    panStart = DateTime.now();
    panEnd = DateTime.now();
    endTime = startTime.add(Duration(days: addDays));
  }

  @override
  Widget build(BuildContext context) {
    ScreenUtil.init(
        BoxConstraints(
            maxWidth: MediaQuery.of(context).size.width,
            maxHeight: MediaQuery.of(context).size.height),
        designSize: Size(375, 812),
        orientation: Orientation.portrait);
    return Scaffold(
      appBar: AppBarPage(),
      body: Container(
        height: 1.sh,
        child: ListView(
          children: <Widget>[
            ///基本信息
            baseInfor(),

            ///作业票基本信息
            qualityBaseInfor(),

            ///具体人员分工
            divisionOfLabor(),

            ///主要风险
            mainRisks(),

            ///作业必备条件
            operationPrerequisites(),

            ///作业过程风险控制措施
            processRisk(),

            ///审核签名
            auditSignature(),

            ///保存--提交
            saveButton(),
          ],
        ),
      ),
    );
  }

  void timeProcessing(DateTime times) {
    year = "${times.year}";
    months = times.month < 10 ? "0${times.month}" : "${times.month}";
    days = times.day < 10 ? "0${times.day}" : "${times.day}";
  }

  ///基本信息
  Widget baseInfor() {
    return Container(
      width: 1.sw - 32.w,
      // height: isBaseInfoShow ? 168.h : 55.h,
      margin: EdgeInsets.only(left: 16.w, top: 16.h, right: 16.w),
      padding: EdgeInsets.symmetric(horizontal: 16.w),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(4),
      ),
      child: Column(
        children: <Widget>[
          //基本信息--收起
          QulityTitleItem(
            titleLeft: "基本信息",
            isShow: isShowBaseInfo,
            onTap: () {
              if (isShowBaseInfo) {
                isShowBaseInfo = false;
                setState(() {});
              } else {
                isShowBaseInfo = true;
                setState(() {});
              }
            },
          ),
          Offstage(
            offstage: isShowBaseInfo, //这里控制 true  false 布尔值
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Container(
                  height: 0.5.h,
                  color: Color.fromRGBO(233, 233, 233, 1),
                ),
                Container(
                  margin: EdgeInsets.only(top: 10.h),
                  child: Text(
                    "胜利-西渡B线改进英坡110KV线路工程",
                    style:
                        TextStyle(fontSize: 14.sp, color: AppColor.font_black),
                  ),
                ),
                Container(
                  margin: EdgeInsets.only(top: 12.h),
                  child: Text(
                    "作业票类型：实测实量线路工程A票",
                    style:
                        TextStyle(fontSize: 14.sp, color: AppColor.font_grey),
                  ),
                ),
                Container(
                  margin: EdgeInsets.only(top: 8.h, bottom: 18.h),
                  child: Text(
                    "作业票编码：JC-1516A213508001-01",
                    style:
                        TextStyle(fontSize: 14.sp, color: AppColor.font_grey),
                  ),
                ),
              ],
            ),
          ),
        ],
      ),
    );
  }

  ///作业票基本信息
  Widget qualityBaseInfor() {
    return Container(
      width: 1.sw - 32.w,
      margin: EdgeInsets.only(left: 16.w, top: 16.h, right: 16.w),
      padding: EdgeInsets.symmetric(horizontal: 16.w),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(4),
      ),
      child: Column(
        children: <Widget>[
          //作业票基本信息--收起
          QulityTitleItem(
            titleLeft: "作业票基本信息",
            isShow: isShowQualityBaseInfo,
            onTap: () {
              if (isShowQualityBaseInfo) {
                isShowQualityBaseInfo = false;
                setState(() {});
              } else {
                isShowQualityBaseInfo = true;
                setState(() {});
              }
            },
          ),
          Offstage(
            offstage: isShowQualityBaseInfo,
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                //初勘风险等级
                QualityItem(
                    leftString: "初勘风险等级",
                    rightString: "五级",
                    pngUrl: "assets/icon/green_rectangle.png",
                    fontSizes: 15,
                    colors: Color.fromRGBO(43, 202, 21, 1)),
                //复测后风险等级
                QualityItem(
                  leftString: "复测后风险等级",
                  rightString: riskLevelModel.name,
                  pngUrl: riskLevelModel.url,
                  colors: riskLevelModel.colors,
                  isNextItem: false,
                  onTap: () {
                    riskLevelBottomSheet();
                  },
                ),
                //工序及作业内容
                Container(
                  margin: EdgeInsets.only(top: 19.h),
                  child: Text(
                    "工序及作业内容",
                    style:
                        TextStyle(fontSize: 14.sp, color: AppColor.font_black),
                  ),
                ),
                Container(
                  margin: EdgeInsets.only(top: 8.h, bottom: 16.h),
                  child: Text(
                    "桩基础检测；变电钢结构厂房防火材料覆盖厚度检测",
                    style:
                        TextStyle(fontSize: 14.sp, color: AppColor.font_black),
                  ),
                ),
                //计划开始时间
                QualityItem(
                  leftString: "计划开始时间",
                  rightString: panStartTime,
                  colors: AppColor.font_grey,
                  onTap: () {
                    print("计划开始时间");
                    showModalBottomSheet(
                        context: context,
                        builder: (context) {
                          return Container(
                            child: MonthPicker(
                              selectedDate: panStart,
                              onChanged: (date) {
                                //修改计划结束时间的范围
                                panStart = date;
                                startTime = date;
                                endTime =
                                    startTime.add(Duration(days: addDays));
                                panEnd = date;
                                //判断结束计划时间是否可选
                                isSingleClickEndTime = true;
                                timeProcessing(date);
                                panStartTime = "$year-$months-$days";
                                setState(() {});
                                Navigator.pop(context);
                              },
                              firstDate: DateTime(startTime.year,
                                  startTime.month, startTime.day),
                              lastDate: DateTime(
                                  endTime.year, endTime.month, endTime.day),
                            ),
                          );
                        });
                  },
                ),
                //计划结束时间
                QualityItem(
                  leftString: "计划结束时间",
                  rightString: panEndTime,
                  colors: AppColor.font_grey,
                  onTap: () {
                    print("计划结束时间");
                    if (isSingleClickEndTime) {
                      showModalBottomSheet(
                          context: context,
                          builder: (context) {
                            return Container(
                              child: MonthPicker(
                                selectedDate: panEnd,
                                onChanged: (date) {
                                  panEnd = date;
                                  //调取时间处理方法
                                  timeProcessing(date);
                                  //判断结束时间是否比开始时间小
                                  panEndTime = "$year-$months-$days";
                                  //开始结束时间处理
                                  startTime = DateTime.now();
                                  endTime = date;
                                  Navigator.pop(context);
                                  setState(() {});
                                },
                                firstDate: DateTime(startTime.year,
                                    startTime.month, startTime.day),
                                lastDate: DateTime(
                                    endTime.year, endTime.month, endTime.day),
                              ),
                            );
                          });
                    } else {
                      Toast.show("请先选择计划开始时间", context,
                          duration: Toast.LENGTH_SHORT, gravity: Toast.BOTTOM);
                    }
                  },
                ),
                //执行方案名称
                QualityItem(
                    leftString: "执行方案名称",
                    rightString: "演示1执行方案",
                    colors: AppColor.font_grey,
                    isNextItem: false),
                //方案技术要点
                Container(
                  margin: EdgeInsets.only(top: 20.h),
                  child: Text(
                    "方案技术要点",
                    style:
                        TextStyle(fontSize: 14.sp, color: AppColor.font_black),
                  ),
                ),
                Container(
                  margin: EdgeInsets.only(top: 7.h, bottom: 53.h),
                  child: Text(
                    "方案主要要点包括。。。。。。。。。。。。。。。。",
                    style:
                        TextStyle(fontSize: 14.sp, color: AppColor.font_black),
                  ),
                ),
              ],
            ),
          )
        ],
      ),
    );
  }

  ///具体人员分工
  Widget divisionOfLabor() {
    return Container(
      width: 1.sw - 32.w,
      margin: EdgeInsets.only(left: 16.w, top: 16.h, right: 16.w),
      padding: EdgeInsets.symmetric(horizontal: 16.w),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(4),
      ),
      child: Column(
        children: <Widget>[
          //具体人员分工--收起
          QulityTitleItem(
            titleLeft: "具体人员分工",
            isShow: isShowDivisionOfLabor,
            onTap: () {
              if (isShowDivisionOfLabor) {
                isShowDivisionOfLabor = false;
                setState(() {});
              } else {
                isShowDivisionOfLabor = true;
                setState(() {});
              }
            },
          ),
          Offstage(
            offstage: isShowDivisionOfLabor,
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                //工作负责人
                QualityItem(
                    leftString: "工作负责人",
                    rightString: "李杰华",
                    colors: AppColor.font_grey),
                //安全监护人
                QualityItem(
                    leftString: "安全监护人",
                    rightString: "李杰华",
                    colors: AppColor.font_grey),
                //其他施工人员
                Container(
                  height: 60.h,
                  decoration: BoxDecoration(
                    border: Border(
                      top: BorderSide(
                        width: 0.5.h, //宽度
                        color: Color.fromRGBO(233, 233, 233, 1), //边框颜色
                      ),
                    ),
                  ),
                  child: Row(
                    children: <Widget>[
                      Text(
                        "其他施工人员",
                        style: TextStyle(
                            fontSize: 14.sp, color: AppColor.font_black),
                      ),
                      Spacer(),
                      Container(
                        width: 60.w,
                        height: 24.h,
                        alignment: Alignment.center,
                        decoration: BoxDecoration(
                          border: Border.all(
                              width: 0.5,
                              color: Color.fromRGBO(66, 134, 237, 1)),
                          borderRadius: BorderRadius.circular(50),
                        ),
                        child: Text(
                          "签字",
                          style: TextStyle(
                              fontSize: 12.sp,
                              color: Color.fromRGBO(66, 134, 237, 1)),
                        ),
                      ),
                    ],
                  ),
                ),
              ],
            ),
          )
        ],
      ),
    );
  }

  ///主要风险
  Widget mainRisks() {
    return Container(
      width: 1.sw - 32.w,
      margin: EdgeInsets.only(left: 16.w, top: 16.h, right: 16.w),
      padding: EdgeInsets.symmetric(horizontal: 16.w),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(4),
      ),
      child: Column(
        children: <Widget>[
          //主要风险--收起
          QulityTitleItem(
            titleLeft: "主要风险",
            isShow: isShowMainRisks,
            onTap: () {
              if (isShowMainRisks) {
                isShowMainRisks = false;
                setState(() {});
              } else {
                isShowMainRisks = true;
                setState(() {});
              }
            },
          ),
          Offstage(
            offstage: isShowMainRisks,
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Container(
                  height: 0.5.h,
                  color: Color.fromRGBO(233, 233, 233, 1),
                ),
                Container(
                  margin: EdgeInsets.only(top: 19.h, bottom: 20.h),
                  child: Text(
                    "机械伤害、高处坠落、物体打击、触电、起重伤害、中毒、窒息、火灾、其他伤害等",
                    style:
                        TextStyle(fontSize: 14.sp, color: AppColor.font_black),
                  ),
                ),
              ],
            ),
          )
        ],
      ),
    );
  }

  ///作业必备条件
  Widget operationPrerequisites() {
    return Container(
      width: 1.sw - 32.w,
      margin: EdgeInsets.only(left: 16.w, top: 16.h, right: 16.w),
      padding: EdgeInsets.symmetric(horizontal: 16.w),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(4),
      ),
      child: Column(
        children: <Widget>[
          //作业必备条件--收起
          QulityTitleItem(
            titleLeft: "作业必备条件",
            isShow: isShowOperationPrerequisites,
            onTap: () {
              if (isShowOperationPrerequisites) {
                isShowOperationPrerequisites = false;
                setState(() {});
              } else {
                isShowOperationPrerequisites = true;
                setState(() {});
              }
            },
          ),
          Offstage(
            offstage: isShowOperationPrerequisites,
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                Container(
                  decoration: BoxDecoration(
                    border: Border(
                      top: BorderSide(
                        width: 0.5.h, //宽度
                        color: Color.fromRGBO(233, 233, 233, 1), //边框颜色
                      ),
                    ),
                  ),
                  child: Row(
                    children: <Widget>[
                      Spacer(),
                      Container(
                        child: Text(
                          "全选",
                          style: TextStyle(
                              fontSize: 14.sp, color: AppColor.font_grey),
                        ),
                      ),
                      Container(
                        child: Checkbox(
                          value: allCheckVal,
                          onChanged: (value) {
                            allCheckVal = value;
                            if (allCheckVal) {
                              for (var i = 0;
                                  i < OperatingConditionsList.length;
                                  i++) {
                                OperatingConditionsList[i].checkValue = true;
                              }
                            } else {
                              for (var i = 0;
                                  i < OperatingConditionsList.length;
                                  i++) {
                                OperatingConditionsList[i].checkValue = false;
                              }
                            }
                            setState(() {});
                          },
                        ),
                      ),
                    ],
                  ),
                ),
                //多选循环列表
                Container(
                  margin: EdgeInsets.only(bottom: 20.h),
                  height: (OperatingConditionsList.length * 60).toDouble().h,
                  child: ListView.builder(
                    physics: NeverScrollableScrollPhysics(), //静止滚动
                    itemBuilder: (BuildContext context, int i) {
                      return QulityCheckedItem(
                        list: OperatingConditionsList,
                        index: i,
                        onChanged: (value) {
                          OperatingConditionsList[i].checkValue = value;
                          var mm = 0;
                          int leng = OperatingConditionsList.length;
                          for (var i = 0; i < leng; i++) {
                            if (OperatingConditionsList[i].checkValue) {
                              mm++;
                            }
                          }
                          if (mm == leng) {
                            allCheckVal = true;
                          } else {
                            allCheckVal = false;
                          }
                          setState(() {});
                        },
                      );
                    },
                    itemCount: OperatingConditionsList.length,
                  ),
                ),
              ],
            ),
          )
        ],
      ),
    );
  }

  ///作业过程风险控制措施
  Widget processRisk() {
    return Container(
      width: 1.sw - 32.w,
      margin: EdgeInsets.only(left: 16.w, top: 16.h, right: 16.w),
      padding: EdgeInsets.symmetric(horizontal: 16.w),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(4),
      ),
      child: Column(
        children: <Widget>[
          //作业过程风险控制措施--收起
          QulityTitleItem(
            titleLeft: "作业过程风险控制措施",
            isShow: isShowProcessRisk,
            onTap: () {
              if (isShowProcessRisk) {
                isShowProcessRisk = false;
                setState(() {});
              } else {
                isShowProcessRisk = true;
                setState(() {});
              }
            },
          ),
          Offstage(
            offstage: isShowProcessRisk,
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: <Widget>[
                //关键点作业安全控制措施
                Container(
                  height: 60.h,
                  width: 1.sw - 32.w,
                  decoration: BoxDecoration(
                    border: Border(
                      top: BorderSide(
                        width: 0.5.h,
                        color: Color.fromRGBO(233, 233, 233, 1),
                      ),
                    ),
                  ),
                  padding: EdgeInsets.only(top: 19.h, bottom: 10.h),
                  child: Text(
                    "关键点作业安全控制措施",
                    style:
                        TextStyle(fontSize: 14.sp, color: AppColor.font_black),
                  ),
                ),
                Container(
                  height: 88.h,
                  padding: EdgeInsets.only(top: 10.h, left: 14.w, right: 15.h),
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(4.h),
                    color: Color.fromRGBO(247, 247, 247, 1),
                  ),
                  child: FocusWidget(
                    focusNode: _keyPointsFocus,
                    child: TextField(
                      focusNode: _keyPointsFocus,
                      style:
                          TextStyle(fontSize: 12.sp, color: AppColor.font_grey),
                      cursorColor: AppColor.font_grey,
                      minLines: 1,
                      maxLines: 5,
                      decoration: InputDecoration(
                        isDense: true, //取消TextFiled的焦点样式
                        contentPadding: EdgeInsets.symmetric(
                            horizontal: 0, vertical: 0), //内容内边距，影响高度
                        border: InputBorder.none,
                        counterText: '',
                      ),
                    ),
                  ),
                ),
                //安全综合控制措施
                Container(
                  height: 60.h,
                  decoration: BoxDecoration(
                    border: Border(
                      top: BorderSide(
                        width: 0.5.h,
                        color: Color.fromRGBO(233, 233, 233, 1),
                      ),
                    ),
                  ),
                  padding: EdgeInsets.only(top: 19.h, bottom: 10.h),
                  child: Text(
                    "安全综合控制措施",
                    style:
                        TextStyle(fontSize: 14.sp, color: AppColor.font_black),
                  ),
                ),
                Container(
                  height: 88.h,
                  padding: EdgeInsets.only(top: 10.h, left: 14.w, right: 15.h),
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(4.h),
                    color: Color.fromRGBO(247, 247, 247, 1),
                  ),
                  child: FocusWidget(
                    focusNode: _safetySynthesisFocus,
                    child: TextField(
                      focusNode: _safetySynthesisFocus,
                      style:
                          TextStyle(fontSize: 12.sp, color: AppColor.font_grey),
                      cursorColor: AppColor.font_grey,
                      minLines: 1,
                      maxLines: 5,
                      decoration: InputDecoration(
                        isDense: true,
                        contentPadding: EdgeInsets.symmetric(
                            horizontal: 0, vertical: 0), //内容内边距，影响高度
                        border: InputBorder.none,
                        counterText: '',
                      ),
                    ),
                  ),
                ),
                //现场风险复测变化情况及补充控制措施
                Container(
                  margin: EdgeInsets.only(top: 20),
                  child: Text(
                    "现场风险复测变化情况及补充控制措施",
                    style:
                        TextStyle(fontSize: 14.sp, color: AppColor.font_black),
                  ),
                ),
                //变化情况
                Container(
                  height: 44.h,
                  alignment: Alignment.centerLeft,
                  child: Text(
                    "1.变化情况",
                    style:
                        TextStyle(fontSize: 14.sp, color: AppColor.font_black),
                  ),
                ),
                Container(
                  height: 88.h,
                  padding: EdgeInsets.only(top: 10.h, left: 14.w, right: 15.h),
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(4.h),
                    color: Color.fromRGBO(247, 247, 247, 1),
                  ),
                  child: FocusWidget(
                    focusNode: _changesFocus,
                    child: TextField(
                      focusNode: _changesFocus,
                      style:
                          TextStyle(fontSize: 12.sp, color: AppColor.font_grey),
                      cursorColor: AppColor.font_grey,
                      minLines: 1,
                      maxLines: 5,
                      decoration: InputDecoration(
                        isDense: true,
                        contentPadding: EdgeInsets.symmetric(
                            horizontal: 0, vertical: 0), //内容内边距，影响高度
                        border: InputBorder.none,
                        counterText: '',
                      ),
                    ),
                  ),
                ),
                //控制措施
                Container(
                  height: 44.h,
                  alignment: Alignment.centerLeft,
                  child: Text(
                    "2.控制措施",
                    style:
                        TextStyle(fontSize: 14.sp, color: AppColor.font_black),
                  ),
                ),
                Container(
                  height: 88.h,
                  padding: EdgeInsets.only(top: 10.h, left: 14.w, right: 15.h),
                  margin: EdgeInsets.only(bottom: 20.h),
                  decoration: BoxDecoration(
                    borderRadius: BorderRadius.circular(4.h),
                    color: Color.fromRGBO(247, 247, 247, 1),
                  ),
                  child: FocusWidget(
                    focusNode: _controlMeasuresFocus,
                    child: TextField(
                      focusNode: _controlMeasuresFocus,
                      style:
                          TextStyle(fontSize: 12.sp, color: AppColor.font_grey),
                      cursorColor: AppColor.font_grey,
                      minLines: 1,
                      maxLines: 5,
                      decoration: InputDecoration(
                        isDense: true,
                        contentPadding: EdgeInsets.symmetric(
                            horizontal: 0, vertical: 0), //内容内边距，影响高度
                        border: InputBorder.none,
                        counterText: '',
                      ),
                    ),
                  ),
                ),
              ],
            ),
          )
        ],
      ),
    );
  }

  ///审核签名
  Widget auditSignature() {
    return Container(
      width: 1.sw - 32.w,
      margin: EdgeInsets.only(left: 16.w, top: 16.h, right: 16.w),
      padding: EdgeInsets.symmetric(horizontal: 16.w),
      decoration: BoxDecoration(
        color: Colors.white,
        borderRadius: BorderRadius.circular(4),
      ),
      child: Column(
        children: <Widget>[
          //审核签名--收起
          QulityTitleItem(
            titleLeft: "审核签名",
            isShow: isShowAuditSignature,
            onTap: () {
              if (isShowAuditSignature) {
                isShowAuditSignature = false;
                setState(() {});
              } else {
                isShowAuditSignature = true;
                setState(() {});
              }
            },
          ),
          Offstage(
            offstage: isShowAuditSignature,
            child: Container(
              height: (auditSignatureList.length * 60).toDouble().h,
              child: ListView.builder(
                physics: NeverScrollableScrollPhysics(), //静止滚动
                itemBuilder: (BuildContext context, int index) {
                  return auditSignatureItem(auditSignatureList[index]);
                },
                itemCount: auditSignatureList.length,
              ),
            ),
          )
        ],
      ),
    );
  }

  ///审核签名-Item
  Widget auditSignatureItem(String titles) {
    return Container(
      height: 60.h,
      decoration: BoxDecoration(
        border: Border(
          top: BorderSide(
            width: 0.5,
            color: Color.fromRGBO(233, 233, 233, 1),
          ),
        ),
      ),
      child: Row(
        children: <Widget>[
          Text(
            "$titles",
            style: TextStyle(fontSize: 14.sp, color: AppColor.font_black),
          ),
          Spacer(),
          Container(
            width: 60.w,
            height: 24.h,
            alignment: Alignment.center,
            decoration: BoxDecoration(
              border: Border.all(
                  width: 0.5, color: Color.fromRGBO(66, 134, 237, 1)),
              borderRadius: BorderRadius.circular(50),
            ),
            child: Text(
              "签字",
              style: TextStyle(
                  fontSize: 12.sp, color: Color.fromRGBO(66, 134, 237, 1)),
            ),
          ),
        ],
      ),
    );
  }

  ///保存--提交
  Widget saveButton() {
    return Container(
      width: 1.sw - 32.w,
      margin: EdgeInsets.only(left: 16.w, top: 16.h, right: 16.w, bottom: 24.h),
      child: Row(
        children: <Widget>[
          //保存
          Container(
            width: 112.w,
            height: 42.h,
            child: FlatButton(
              child: Text(
                '保存',
                style: TextStyle(
                    fontSize: 14.sp, color: Color.fromRGBO(66, 134, 237, 1)),
              ),
              onPressed: () {},
              color: Color.fromRGBO(255, 255, 255, 1),
              shape: OutlineInputBorder(
                  borderSide: BorderSide(
                      width: 1, color: Color.fromRGBO(66, 134, 237, 1)),
                  borderRadius: BorderRadius.circular(21)),
            ),
          ),
          //提交
          Container(
            width: 215.w,
            height: 42.h,
            margin: EdgeInsets.only(left: 16.w),
            child: FlatButton(
              child: Text(
                '提交',
                style: TextStyle(
                    fontSize: 14.sp, color: Color.fromRGBO(255, 255, 255, 1)),
              ),
              onPressed: () async {
               var zz=await QualityDialogItem(dataList: conditionList,choiceList:choiceLists).dialogTestss(context);
               choiceLists=[];
               choiceLists=zz;
               print("========================${choiceLists.toString()}=====================");
               setState(() {
               });
                },
              color: Color.fromRGBO(66, 134, 237, 1),
              shape: OutlineInputBorder(
                  borderSide: BorderSide.none,
                  borderRadius: BorderRadius.circular(21)),
            ),
          ),
        ],
      ),
    );
  }

  ///复测后风险等级弹框
  Future riskLevelBottomSheet() {
    return showModalBottomSheet(
        context: context,
        builder: (context) {
          return Container(
            height: 1.sh / 3,
            child: ListView.builder(
              itemBuilder: (BuildContext context, int i) {
                return GestureDetector(
                  onTap: () {
                    switch (i + 1) {
                      case 2:
                        riskLevelModel.name = "二级";
                        riskLevelModel.url = "assets/icon/red_rectangle.png";
                        riskLevelModel.colors = Color.fromRGBO(255, 63, 63, 1);
                        setState(() {});
                        Navigator.pop(context);
                        break;
                      case 3:
                        riskLevelModel.name = "三级";
                        riskLevelModel.url = "assets/icon/orange_rectangle.png";
                        riskLevelModel.colors = Color.fromRGBO(255, 167, 88, 1);
                        setState(() {});
                        Navigator.pop(context);
                        break;
                      case 4:
                        riskLevelModel.name = "四级";
                        riskLevelModel.url = "assets/icon/blue_rectangle.png";
                        riskLevelModel.colors = Color.fromRGBO(66, 134, 237, 1);
                        setState(() {});
                        Navigator.pop(context);
                        break;
                      case 5:
                        riskLevelModel.name = "五级";
                        riskLevelModel.url = "assets/icon/green_rectangle.png";
                        riskLevelModel.colors = Color.fromRGBO(43, 202, 21, 1);
                        setState(() {});
                        Navigator.pop(context);
                        break;
                    }
                  },
                  child: Container(
                    height: (1.sh / 3) / 6,
                    color: Colors.white,
                    margin: EdgeInsets.only(top: 5.h),
                    alignment: Alignment.center,
                    child: Text(riskLevelList[i]),
                  ),
                );
              },
              itemCount: riskLevelList.length,
            ),
          );
        });
  }

  ///多选弹框测试
  Future dialogTest() {
    return
      showDialog(
          context: context,
          builder: (context) {
            return  StatefulBuilder(builder: (context, state) {
              return     Dialog(
                child: Container(
                  width: (1.sw/4)*3,
                  height: (1.sh/4)*3,
                  padding: EdgeInsets.all(16.h),
                  decoration: BoxDecoration(
                    color: Colors.white,
                  ),
                  child: Column(
                    crossAxisAlignment: CrossAxisAlignment.center,
                    children: <Widget>[
                      Container(
                        child: Text("请选择数据",style: TextStyle(fontSize: 16.sp,color: AppColor.font_black),),
                      ),
                      Container(
                        height: 40.h,
                        padding: EdgeInsets.only(left: 16.w,right: 16.w,top: 10.h,bottom: 10.h),
                        margin: EdgeInsets.symmetric(vertical: 16.h),
                        decoration: BoxDecoration(
                          borderRadius: BorderRadius.circular(20.w),
                          border: Border.all(width:0.5.w,color: AppColor.font_grey),
                        ),
                        child: Row(
                          children: <Widget>[
                            Expanded(
                              child: TextField(
                                cursorColor:Colors.grey,
                                style: TextStyle(fontSize: 14.sp,color: AppColor.font_black),
                                decoration: InputDecoration(
                                  hintText: '请输入搜索内容',
                                  hintStyle: TextStyle(color: Colors.grey,fontSize: 14.sp),
                                  hintMaxLines: 1,
                                  isDense: true, //取消TextFiled的焦点样式
                                  contentPadding: EdgeInsets.symmetric(
                                      horizontal: 0, vertical: 0), //内容内边距，影响高度
                                  border: InputBorder.none,
                                  counterText: '',
                                ),
                                onChanged: (value){
                                  serchOperatingConditionsList=[];
                                  for(var i=0;i<OperatingConditionsList.length;i++){
                                    if(OperatingConditionsList[i].condition_val.contains(value)){
                                      serchOperatingConditionsList.add(OperatingConditionsList[i]);
                                    }
                                  }
                                  state(() {
                                  });
                                },
                              ),

                            ),
                            SizedBox(
                              width: 10.w,
                            ),
                            Image.asset("assets/icon/cancel.png",height: 14.h,width: 14.w,),
                          ],
                        ),
                      ),
                      Expanded(
                        child: ListView.builder(
                          itemBuilder: (BuildContext context, int index) {
                            return dialogCheckTest(index);
                          },
                          itemCount:serchOperatingConditionsList.isNotEmpty?serchOperatingConditionsList.length: OperatingConditionsList.length,
                        ),
                      ),
                      Container(
                        height: 60.h,
                        child: Row(
                          children: <Widget>[
                            Text("取消",style: TextStyle(fontSize: 14.sp,color: AppColor.font_black),),
                            Spacer(),
                            Text("确定",style: TextStyle(fontSize: 14.sp,color: AppColor.font_black),),
                          ],
                        ),
                      ),
                    ],
                  ),
                ),
              );});


          }
      );
  }

  Widget dialogCheckTest(int index){
    String condition_val =serchOperatingConditionsList.isNotEmpty?serchOperatingConditionsList[index].condition_val: OperatingConditionsList[index].condition_val;
    bool checkValue = OperatingConditionsList[index].checkValue;
    return   StatefulBuilder(builder: (context, state) {
      return  Container(
        decoration: BoxDecoration(
          border: Border(
            top: BorderSide(
              width: 0.5.h, //宽度
              color: Color.fromRGBO(233, 233, 233, 1), //边框颜色
            ),
          ),
        ),
        child: Row(
          children: <Widget>[
            Expanded(
              child:
              Text(
                '${index + 1}.$condition_val',
                style: TextStyle(fontSize: 14.sp, color: AppColor.font_black),
              ),
            ),
            Checkbox(
              value: serchOperatingConditionsList.isNotEmpty?serchOperatingConditionsList[index].checkValue
                  : OperatingConditionsList[index].checkValue,
              onChanged:(value){
                print("===========$value============");
                state(() {
                  serchOperatingConditionsList.isNotEmpty?(serchOperatingConditionsList[index].checkValue=value)
                      : (OperatingConditionsList[index].checkValue=value);
                  // OperatingConditionsList[index].checkValue=value;
                });
              },
            ),
          ],
        ),
      );
    });

  }
}
